var e = getApp(), t = require("../../../component/WxNotificationCenter/WxNotificationCenter.js");

Page({
    data: {
        roles: [ "主持人", "化妆师", "摄像师", "摄影师", "督导师", "其他" ],
        roleSelect: 0,
        time: 0,
        date: "",
        city: "广州市",
        province: "广东省",
        area: "天河区",
        hotel: "",
        comment: "",
        minPrice: "",
        maxPrice: "",
        priceText: "",
        hadShowRole: !1
    },
    didSelectDate: function(e) {
        var t = e.detail;
        console.log(t), this.setData({
            time: t.time,
            date: t.date
        }), this.data.dateSelector.hide(), 0 == this.data.hadShowRole && (this.data.roleSelector.show(), 
        this.data.hadShowRole = !0);
    },
    didSelectRole: function(e) {
        var t = e.detail.index;
        if (t > 4) {
            var i = [ "主持人", "化妆师", "摄像师", "摄影师", "督导师", "花艺师", "灯光师", "场布", "车队", "设计师", "婚纱", "歌手", "乐器", "舞蹈", "杂技", "魔术", "演员", "音响师", "喜娘", "大屏" ];
            this.setData({
                roles: i
            });
        }
        this.setData({
            roleSelect: t
        }), this.data.roleSelector.hide(), this.data.priceSelector.show();
    },
    didSelectPrice: function(e) {
        this.data.priceSelector.hide();
        var t, i = e.detail;
        "价格详谈" == i.minPrice ? (t = "价格详谈", i.minPrice = "0", i.maxPrice = "0") : t = i.minPrice + "-" + i.maxPrice, 
        this.setData({
            minPrice: i.minPrice,
            maxPrice: i.maxPrice,
            priceText: t
        });
    },
    clickRole: function(e) {
        var t = e.currentTarget.dataset.index;
        if ("其他" == e.currentTarget.dataset.name) {
            var i = [ "主持人", "化妆师", "摄像师", "摄影师", "督导师", "花艺师", "灯光师", "场布", "车队", "设计师", "婚纱", "歌手", "乐器", "舞蹈", "杂技", "魔术", "演员", "音响师", "喜娘", "大屏" ];
            this.setData({
                roles: i
            });
        } else this.setData({
            roleSelect: t
        });
    },
    bindDateChange: function(e) {
        console.log("picker发送选择改变，携带值为", e.detail), this.setData({
            time: e.detail.timepoint,
            date: e.detail.date
        });
    },
    clickCity: function(e) {
        wx.navigateTo({
            url: "../../me/editInfo/editCity/editCity?backResult=1"
        });
    },
    clickPrice: function(e) {
        this.data.priceSelector.show();
    },
    clickDate: function(e) {
        this.data.dateSelector.show();
    },
    bindSummary: function(e) {
        this.setData({
            comment: e.detail.value
        });
    },
    clickOk: function(i) {
        var a = this.data.roleSelect + 2, o = this.data.time, n = this.data.city, c = this.data.province, r = this.data.area, s = this.data.priceText, l = this.data.comment, d = this.data.date;
        if (0 != c.length) if (0 != s.length) {
            var h = this;
            e.network.post({
                url: e.url.PublishWeddingOrder,
                params: {
                    role: a,
                    province: c,
                    city: n,
                    county: r,
                    minPrice: h.data.minPrice.replace("元", ""),
                    maxPrice: h.data.maxPrice.replace("元", ""),
                    comment: l,
                    weddingOrderDate: d,
                    time: o
                },
                before: function() {
                    wx.showLoading({
                        title: "正在发送"
                    });
                },
                success: function(i) {
                    if (wx.hideLoading(), 1 == i.data.result) {
                        e.util.showToast("发单成功"), t.postNotificationName("NeedUpdateOrderAskList");
                        var a = getCurrentPages(), o = a[a.length - 2];
                        void 0 != o.needClose && o.setData({
                            needClose: !0
                        }), setTimeout(function() {
                            wx.showTabBar({}), wx.switchTab({
                                url: e.globalData.currentTab,
                                success: function(e) {
                                    wx.navigateTo({
                                        url: "/pages/sendOrder/orderDetail/orderDetail?weddingOrderId=" + i.data.data.weddingOrderId
                                    });
                                }
                            });
                        }, 1500);
                    } else e.util.showToast(i.data.message);
                },
                fail: function() {
                    wx.hideLoading(), e.util.showToast("发单失败，请重试");
                },
                complete: function() {}
            });
        } else e.util.showToast("请输入价格"); else e.util.showToast("请先选择城市");
    },
    onLoad: function(t) {
        this.data.dateSelector = this.selectComponent("#timeSelector"), this.data.dateSelector.show(), 
        this.data.priceSelector = this.selectComponent("#priceSelector"), this.data.roleSelector = this.selectComponent("#roleSelector");
        var i = wx.getStorageSync(e.storage.userInfo).info;
        this.setData({
            province: i.province,
            city: i.city,
            area: i.county
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {
        var t = e.util.getShareInfo();
        return {
            title: e.globalData.commonShareTitle,
            path: t[0],
            imageUrl: t[1],
            success: function(e) {},
            fail: function(e) {}
        };
    }
});